import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-11-04
 * Time:16:51
 */
class Solution {
public int firstUniqChar(String s) {
        int[] array=new int[26];
        for (int i = 0; i < s.length(); i++) {
            array[s.charAt(i)-'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            if(array[s.charAt(i)-'a']==1){
                return i;
            }
        }
        return -1;
    }
}
public class Test {
    //第一个重复的数据出现

    //不重复的数据
    public static void func1(int []array){
        HashSet<Integer> hashSet=new HashSet<>();
        for(int i = 0; i < array.length; i++) {
            hashSet.add(array[i]);
        }
        System.out.println(hashSet);
    }
    //统计每个数据出现多少次
    public static void func(int []array){
        HashMap<Integer,Integer> hashMap=new HashMap<>();
        for (int key : array) {
            if (hashMap.get(key) == null) {
                hashMap.put(key, 1);
            } else {
                int val = hashMap.get(key);
                hashMap.put(key, val + 1);
            }
        }
        //输出
        for (Map.Entry<Integer,Integer> entry:hashMap.entrySet()) {
            System.out.println(entry);
        }
    }
    public static void main(String[] args) {
        TreeMap<String,Integer> map=new TreeMap<>();
        map.put("hello",2);
        map.put("bit",4);
        Set<Map.Entry<String,Integer>> set= map.entrySet();
        for (Map.Entry<String,Integer> entry:set) {
            System.out.println(entry);
        }
    }
}
